package com.sun2.booksotong.action.user;

import org.springframework.beans.factory.annotation.Autowired;

import com.opensymphony.xwork2.ActionSupport;
import com.sun2.booksotong.service.user.Service4User;

@SuppressWarnings("serial")
public class ForgotAction extends ActionSupport {

	@Autowired
	private Service4User service4User;

	private String account;

	private String message;
	
	@Override
	public String execute() throws Exception {
		if (account == null || account.equals("")) {
			return INPUT;
		}
		try {
			service4User.forgot(account);
			message = "Email로 새 비밀번호를 보냈습니다.";
			return SUCCESS;
		} catch (Exception e) {
			message = (e.getCause() == null) ? e.getLocalizedMessage() : e.getCause().getMessage();
			return ERROR;
		}
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
}
